package net.shopxx.entity;


import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Transient;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * 实体类 - 首页楼层
 */

@Entity
public class Indexfloor extends BaseEntity {
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1795188801804290753L;
	private String name;
	private Integer orderList;
	private Boolean isEnabled;
	private List<ProductCategory> productCategoryList = new ArrayList<ProductCategory>();
	private List<Indexfloortab> indexfloortabList;
	private List<Indexflooradv> indexflooradvList;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    
    public Integer getOrderList() {
        return orderList;
    }
    public void setOrderList(Integer orderList) {
        this.orderList = orderList;
    }
    public Boolean getIsEnabled() {
        return isEnabled;
    }
    public void setIsEnabled(Boolean isEnabled) {
        this.isEnabled = isEnabled;
    }
    
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "indexfloor")
    @OrderBy("orderList asc")
    public List<ProductCategory> getProductCategoryList() {
        return this.productCategoryList;
    }
    
    
    public void setProductCategoryList(List<ProductCategory> productCategoryList) {
        this.productCategoryList = productCategoryList;
    }
    
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "indexfloor")
    @Cascade(value = { CascadeType.DELETE })
    @OrderBy("orderList asc")
    public List<Indexfloortab> getIndexfloortabList() {
        return indexfloortabList;
    }
    public void setIndexfloortabList(List<Indexfloortab> indexfloortabList) {
        this.indexfloortabList = indexfloortabList;
    }
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "indexfloor")
    @Cascade(value = { CascadeType.DELETE })
    @OrderBy("orderList asc")
    public List<Indexflooradv> getIndexflooradvList() {
        return indexflooradvList;
    }
    public void setIndexflooradvList(List<Indexflooradv> indexflooradvList) {
        this.indexflooradvList = indexflooradvList;
    }
    // 获得已启用的楼层tab
    @Transient
    public List<Indexfloortab> getEnabledIndexfloortabList() {
        if (indexfloortabList == null) {
            return null;
        }
        List<Indexfloortab> enabledIndexfloortabList = new ArrayList<Indexfloortab>();
        for (Indexfloortab indexfloortab : indexfloortabList) {
            if (indexfloortab.getIsEnabled()) {
                enabledIndexfloortabList.add(indexfloortab);
            }
        }
        return enabledIndexfloortabList;
    }
	
 // 获得已启用的楼层滚动图
    @Transient
    public List<Indexflooradv> getEnabledIndexflooradvList() {
        if (indexflooradvList == null) {
            return null;
        }
        List<Indexflooradv> enabledIndexflooradvList = new ArrayList<Indexflooradv>();
        for (Indexflooradv indexflooradv : indexflooradvList) {
            if (indexflooradv.getIsEnabled()) {
                enabledIndexflooradvList.add(indexflooradv);
            }
        }
        return enabledIndexflooradvList;
    }
	
}